<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath }"/>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8" />
	<title>低值资产管理系统</title>
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta content="width=device-width, initial-scale=1.0" name="viewport" />
	<meta content="" name="description" />
	<meta content="" name="author" />
	<meta name="MobileOptimized" content="320">
	<!-- BEGIN GLOBAL MANDATORY STYLES -->          
	<link href="${ctx}/assets/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css"/>
	<link href="${ctx}/assets/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
	<link href="${ctx}/assets/plugins/uniform/css/uniform.default.css" rel="stylesheet" type="text/css"/>
	<!-- END GLOBAL MANDATORY STYLES -->
	<!-- BEGIN PAGE LEVEL STYLES -->
	<link rel="stylesheet" type="text/css" href="${ctx}/assets/plugins/fuelux/css/tree-metronic.css" />
	<!-- END PAGE LEVEL STYLES -->
	<!-- BEGIN THEME STYLES --> 
	<link href="${ctx}/assets/css/style-metronic.css" rel="stylesheet" type="text/css"/>
	<link href="${ctx}/assets/css/style.css" rel="stylesheet" type="text/css"/>
	<link href="${ctx}/assets/css/style-responsive.css" rel="stylesheet" type="text/css"/>
	<link href="${ctx}/assets/css/plugins.css" rel="stylesheet" type="text/css"/>
	<link href="${ctx}/assets/css/themes/light.css" rel="stylesheet" type="text/css"/>
	<link href="${ctx}/assets/css/custom.css" rel="stylesheet" type="text/css"/>
	<link href="${ctx }/css/custom.css" rel="stylesheet" type="text/css"/>
	<!-- END THEME STYLES -->	
	
	<link rel="shortcut icon" href="favicon.ico" />
	<style type="text/css">
		.page-content{
			min-height:900px;
		}
	</style>
</head>
<!-- END HEAD -->
<!-- BEGIN BODY -->
<body class="page-header-fixed">
	<!-- BEGIN HEADER -->
	<%@include file="../include/header.jsp" %>
	<!-- END HEADER -->	
	<div class="clearfix"></div>
	<!-- BEGIN CONTAINER -->   
	<div class="page-container">
		<!-- BEGIN SIDEBAR -->
		<%@include file="../include/sidebar.jsp" %>
		<!-- END SIDEBAR -->
		<!-- BEGIN PAGE -->
		<div class="page-content">
			<!-- BEGIN PAGE HEADER-->
			<div class="row">
				<div class="col-md-12">
					<!-- BEGIN PAGE TITLE & BREADCRUMB-->
					<h3 class="page-title">
						LDAP设置
					</h3>					
					<!-- END PAGE TITLE & BREADCRUMB-->
				</div>
			</div>
			<hr>
			<!-- END PAGE HEADER-->
			<!-- BEGIN PAGE CONTENT-->			
			<div class="row">				
				<div class="col-md-12">
					<div class="portlet box blue">
						<div class="portlet-title">
							<div class="caption"><i class="fa fa-cogs"></i>LDAP参数设置</div>
						</div>
						<div class="portlet-body flip-scroll">
							<form class="form-horizontal" role="form" id="ldapXianShi">
								<div style="text-align:right;">
									<a class="btn blue" id="xiuGaiAN"><i class="fa fa-search"></i>&nbsp;&nbsp;修改</a>
								</div><br>								
								<div class="row">
									<div class="col-md-12">
										<div class="form-group">
											<label class="col-md-2 control-label">LDAP url</label>											
											<label class="col-md-4 control-label" style="text-align:left;">${ldap.url}</label>
											<label class="col-md-2 control-label">LDAP 用户名</label>
											<label class="col-md-4 control-label" style="text-align:left;">${ldap.adminName}</label>
										</div>
										<div class="form-group">
											<label class="col-md-2 control-label">LDAP 密码</label>										
											<label class="col-md-4 control-label" style="text-align:left;">${ldap.adminPassword}</label>
											<label class="col-md-2 control-label">LDAP 搜索基础词</label>
											<label class="col-md-4 control-label" style="text-align:left;">${ldap.searchBase}</label>
										</div>
									</div>
								</div>
							</form>
							<form class="form-horizontal" role="form" id="ldap">
								<div style="text-align:right;">
									<a class="btn blue" id="baoCunAN"><i class="fa fa-search"></i>&nbsp;&nbsp;保存修改</a>&nbsp;&nbsp;
									<a class="btn default" id="quXiao"><i class="fa fa-search"></i>&nbsp;&nbsp;返回</a>
								</div><br>
								<input type="hidden" name="id" value="${ldap.id }">
								<div class="row">
									<div class="col-md-12">
										<div class="form-group">
											<label class="col-md-2 control-label">LDAP url</label>
											<div class="col-md-4">
												<input type="text" class="form-control" value="${ldap.url}" name="url">
											</div>
											<label class="col-md-2 control-label">LDAP 用户名</label>
											<div class="col-md-4">
												<input type="text" class="form-control" value="${ldap.adminName}" name="adminName">
											</div>
										</div>
										<div class="form-group">
											<label class="col-md-2 control-label">LDAP 密码</label>
											<div class="col-md-4">
												<input type="text" class="form-control" value="${ldap.adminPassword}" name="adminPassword">
											</div>
											<label class="col-md-2 control-label">LDAP 搜索基础词</label>
											<div class="col-md-4">
												<input type="text" class="form-control" value="${ldap.searchBase}" name="searchBase">
											</div>
										</div>
									</div>
								</div>
							</form>
						</div>
					</div>				
				</div>
			</div>
			<!-- END PAGE CONTENT-->
		</div>
		<!-- END PAGE -->    
	</div>
	<!-- END CONTAINER -->
	<!-- BEGIN FOOTER -->
	<%@include file="../include/footer.jsp" %>
	<!-- END FOOTER -->
	<script src="${ctx}/assets/plugins/jquery-1.10.2.min.js" type="text/javascript"></script>
	<script src="${ctx}/assets/plugins/jquery-migrate-1.2.1.min.js" type="text/javascript"></script>    
	<script src="${ctx}/assets/plugins/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
	<script src="${ctx}/assets/plugins/bootstrap-hover-dropdown/twitter-bootstrap-hover-dropdown.min.js" type="text/javascript" ></script>
	<script src="${ctx}/assets/plugins/jquery-slimscroll/jquery.slimscroll.min.js" type="text/javascript"></script>
	<script src="${ctx}/assets/plugins/jquery.blockui.min.js" type="text/javascript"></script>  
	<script src="${ctx}/assets/plugins/jquery.cookie.min.js" type="text/javascript"></script>
	<script src="${ctx}/assets/plugins/uniform/jquery.uniform.min.js" type="text/javascript" ></script>
	<script src="${ctx}/assets/plugins/jquery-validation/dist/jquery.validate.min.js" type="text/javascript"></script>
	<!-- END CORE PLUGINS -->
	<!-- BEGIN PAGE LEVEL SCRIPTS -->
	<script src="${ctx}/assets/plugins/fuelux/js/tree.min.js"></script>  
	<!-- END PAGE LEVEL SCRIPTS -->
	<script src="${ctx}/assets/scripts/app.js"></script>	
	<script>
		jQuery(document).ready(function() {       
		   // initiate layout and plugins
		   App.init();
		   $('#J').addClass('active');
		   $('#J4').addClass('active');
		   $('#ldap').hide();
		   $('#ldapXianShi').show();
		});
		
		$('#xiuGaiAN').bind('click',function(){
			$('#ldapXianShi').hide();
			$('#ldap').show();			
		});
		
		$('#quXiao').bind('click',function(){
			$('#ldap').hide();
			$('#ldapXianShi').show();
		});
		
		function validateForm() {
			//validate方法参数可选  
			return $("#ldap").validate({
				errorElement: 'span', //default input error message container
	            errorClass: 'help-block', // default input error message class
	            focusInvalid: false, // do not focus the last invalid input
				rules : {
					url : {
						required : true
					},
					adminName : {
						required : true
					},
					adminPassword : {
						required : true
					},
					searchBase : {
						required : true
					}
				},
				messages : {					
					url : {
						required : '请输入LDAP服务器url'
					},
					adminName : {
						required : '请输入LDAP服务器用户名'
					},
					adminPassword : {
						required : '请输入LDAP服务器密码'
					},
					searchBase : {
						required : '请输入LDAP搜索基础词'
					}
				},
				highlight: function (element) { // hightlight error inputs
	                $(element)
	                    .closest('div').addClass('has-error'); // set error class to the control group
	            },
	            success: function (label) {
	                label.closest('div').removeClass('has-error');
	                label.remove();
	            },
				errorPlacement: function(error, element) {  
				    error.appendTo(element.parent());  
				}
			}).form();			
		}
		
		$('#baoCunAN').bind('click',function(){
			if(validateForm()){
				$.ajax({
					type:"POST",
					data:$('#ldap').serialize(),
					url:"${ctx}/system/ldapSave.do",
					dataType:"json",
					async:false,
					success:function(data){
						if(data.result=="success"){
							alert("保存成功");
							window.location.reload();
						}
					}
				});
			}
		});
		
	</script>
	<!-- END JAVASCRIPTS -->
</body>
<!-- END BODY -->
</html>